﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//
using System.Web.Services;
using DDSC.OracleADO;
using System.Collections;
using System.Text;
using System.Data;

public partial class TEST : BasePermissionPage
{
    //維護動作
    public string Mode { get; set; }
    //Grid選取資料
    public static Dictionary<string, string> GridKey { get; set; }
    //查詢條件
    public static Dictionary<string, string> ConditionKey { get; set; }
    //搜尋SQL
    [WebMethod]
    public static Object GetDocument(string F61901, string sType_S, PageInfo p_PageInfo)
    {
        Object results = new Object();
        try
        {
            dbAccess m_dba = new dbAccess();
            StringBuilder m_sb = new StringBuilder();
            ArrayList m_arrParam = new ArrayList();
            if (sType_S == "A")
            {
                m_sb.Append(" select F61901 SHIPPING_NO,F61902 SHIPPING_SEQ,F61906 DISPATCH_DATE,F61907 DISPATCH_DEPT,F61905 RECEIVED_DEPT,F61913 SHIPPER,F61917 RECEIVER,F61925 ITEM_COUNT,'' STATUS,'*' SING  from as400_zdf619 Where 1=1 ");
                if (F61901 != "")
                {
                    m_sb.Append(" AND F61901=:DOCUMENT_NO ");
                    m_arrParam.Add(m_dba.GetOracleParam(":F61901", F61901));
                }
            }
            else
            {
                m_sb.Append(" select F63101 DETAIL_NO,F63102 ITEM_NO,F63104 DISPATCH_DEPT,F63106 RECEIVED_DEPT,F63105 RECEIVED_DATE,F63112 SHIPPER,F63114 RECEIVER,F63119 ITEM_COUNT,'' STATUS,'' SING from as400_zdf631 Where 1=1 ");
                if (F61901 != "")
                {
                    m_sb.Append(" AND F63101=:DOCUMENT_NO ");
                    m_arrParam.Add(m_dba.GetOracleParam(":F63101", F61901));
                }
            }



            results = ADOGridHandler(m_sb, m_arrParam, p_PageInfo);
        }
        catch (Exception ex)
        {
            results = ex.Message;
        }
        return (results);

    }
    //紀錄選取資料及查詢條件
    [WebMethod]
    public static void SetGridKey(Dictionary<string, string> p_Param, Dictionary<string, string> p_ConditionKey)
    {
        ConditionKey = p_ConditionKey;
        GridKey = p_Param;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        //紀錄頁次
        var m_PageIndex = "1";
        //判斷如果是維護頁導回來就填回查詢條件
        if (Page.PreviousPage != null)
        {
            
            //執行搜尋功能
            ClientScript.RegisterClientScriptBlock(this.GetType(), "btnSearch_Click", "<script language='javascript'>$(document).ready(function () { btnSearch_Click('" + m_PageIndex + "'); }) </script>");
        }
    }
    protected void toPage()
    {
        Server.Transfer("~/Management/Tracking/krj_tracking_detail.aspx", false);

    }
    protected void btnADD_Click(object sender, EventArgs e)
    {
        Mode = "Insert";
        toPage();
    }

    protected void btnFIND_Click(object sender, EventArgs e)
    {
        Mode = "View";
        toPage();

    }

    protected void btnEDIT_Click(object sender, EventArgs e)
    {
        Mode = "Update";
        toPage();


    }

    protected void btnDEL_Click(object sender, EventArgs e)
    {
        Mode = "Delete";
        toPage();

    }


    protected void btn_VIEW_Click(object sender, EventArgs e)
    {
        Mode = "View";
        toPage();

    }

}
